//
//  MobileConfig.m
//  gdemm
//
//  Created by 乔明超 on 16/11/15.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "MobileConfig.h"

@implementation MobileConfig
+ (BOOL)IsMobileConfigInstalled{
    NSString *certPath = [[NSBundle mainBundle]pathForResource:@"leaf" ofType:@"cer"];
    NSData *certData = [NSData dataWithContentsOfFile:certPath];
    SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certData);
    SecPolicyRef policy = SecPolicyCreateBasicX509();
    SecTrustRef trust;
    OSStatus err = SecTrustCreateWithCertificates((__bridge CFArrayRef) [NSArray arrayWithObject:(__bridge id)cert], policy, &trust);
    SecTrustResultType trustResult = -1;
    err = SecTrustEvaluate(trust, &trustResult);
    CFRelease(trust);
    
    CFRelease(policy);
    
    CFRelease(cert);
    
    if(trustResult == kSecTrustResultUnspecified){
    
        return YES;
    }
    return NO;

}
@end
